package io.dogstudio.apt;

import android.app.Activity;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import io.dogstudio.contants.Constants;

/**
 * TODO 类描述
 *
 * @author HB.cby
 * @date 2020-10-27
 **/
public final class ViewInject {

	public static void bind(MainActivity activity) {
		if (activity == null) {
			return;
		}
		Class clazz = activity.getClass();
		try {
			Class bindClazz = Class.forName(clazz.getName() + Constants.BUFFER);
			Method method = bindClazz.getMethod("bind", activity.getClass());
			method.invoke(bindClazz.newInstance(), activity);
		} catch (ClassNotFoundException | NoSuchMethodException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
	}
}
